#pragma once
template<class iterator,class Ref,class Ptr>
struct reverseiterator {

	typedef reverseiterator<iterator,Ref,Ptr>self;

	reverseiterator(iterator it)
		:_it(it) {}

	self& operator++() {
		--_it;
		return *this;
	}
	self operator++(int) {
		self tmp = *this;
		--_it;
		return tmp;
	}
	self& operator--() {
		++_it;
		return *this;
	}
	self operator--(int) {
		self tmp = *this;
		++_it;
		return tmp;
	}
	Ref operator*()  {
		iterator cur = _it;
		return *(--cur);
	}
	Ptr operator->() {
		return &(operator*());
	}
	bool operator!=(const self& s) {
		return _it != s._it;
	}
	bool operator==(const self& s) {
		return _it == s._it;
	}

	iterator _it;
};
